﻿using Microsoft.AspNetCore.Mvc;
using tools.algorithm;

namespace tools.api.Controllers
{
    /// <summary>
    /// Aes 工具操作
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AesController : ControllerBase
    {
        private const string _key = "997a53e76f2d728bf4e984ced21df8c3";
        private const string _iv = "5337a36380ba50e8";

        [HttpGet]
        public IActionResult Encrypt(string plainText)
        {
            return Ok(AesTool.Encrypt(null, _iv, plainText));
        }

        [HttpGet]
        public IActionResult Decrypt(string cipherText)
        {
            return Ok(AesTool.Decrypt(_key, _iv, cipherText));
        }
    }
}
